Data from NYC Squirrel Census. Retrieved from jonthegeek originally shared by Sara Stoudt. Pizza Data
library(tidyverse)
nyc_squirrels <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2019/2019-10-29/nyc_squirrels.csv")
## Rows: 3023 Columns: 36
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): unique_squirrel_id, hectare, shift, age, primary_fur_color, highli...
## dbl (9): long, lat, date, hectare_squirrel_number, zip_codes, community_dis...
## lgl (13): running, chasing, climbing, eating, foraging, kuks, quaas, moans, ...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ggplot(data=nyc_squirrels, aes(x=primary_fur_color, fill = primary_fur_color)) +
geom_bar(stat = "count", width = 1) +
scale_fill_manual(values = c("black", "chocolate4","darkgrey")) +
labs(title="NYC Squirrel Fur Color",
xlab = "Number of Observations",
ylab = "Fur Color")

pizza_datafiniti <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-10-01/pizza_datafiniti.csv")
## Rows: 10000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (6): name, address, city, country, province, categories
## dbl (4): latitude, longitude, price_range_min, price_range_max
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
pizza_nyc <- pizza_datafiniti %>%
filter(city == "New York")
names(pizza_nyc)[names(pizza_nyc) == 'longitude'] <- 'long'
names(pizza_nyc)[names(pizza_nyc) == 'latitude'] <- 'lat'
nyc_squirrels <- nyc_squirrels %>%
mutate(source = "squirrels")
pizza_nyc <- pizza_nyc %>%
mutate(source = "pizza")
squirrels_and_pizza <- bind_rows(nyc_squirrels, pizza_nyc)
print(squirrels_and_pizza)
## # A tibble: 3,678 × 45
## long lat unique_squirrel_id hectare shift date hectare_squirrel_number
## <dbl> <dbl> <chr> <chr> <chr> <dbl> <dbl>
## 1 -74.0 40.8 37F-PM-1014-03 37F PM 10142018 3
## 2 -74.0 40.8 37E-PM-1006-03 37E PM 10062018 3
## 3 -74.0 40.8 2E-AM-1010-03 02E AM 10102018 3
## 4 -74.0 40.8 5D-PM-1018-05 05D PM 10182018 5
## 5 -74.0 40.8 39B-AM-1018-01 39B AM 10182018 1
## 6 -74.0 40.8 33H-AM-1019-02 33H AM 10192018 2
## 7 -74.0 40.8 6G-PM-1020-02 06G PM 10202018 2
## 8 -74.0 40.8 35C-PM-1013-03 35C PM 10132018 3
## 9 -74.0 40.8 7B-AM-1008-09 07B AM 10082018 9
## 10 -74.0 40.8 32E-PM-1017-14 32E PM 10172018 14
## # ℹ 3,668 more rows
## # ℹ 38 more variables: age <chr>, primary_fur_color <chr>,
## # highlight_fur_color <chr>,
## # combination_of_primary_and_highlight_color <chr>, color_notes <chr>,
## # location <chr>, above_ground_sighter_measurement <chr>,
## # specific_location <chr>, running <lgl>, chasing <lgl>, climbing <lgl>,
## # eating <lgl>, foraging <lgl>, other_activities <chr>, kuks <lgl>, …
ggplot(squirrels_and_pizza) +
geom_point(mapping = aes(x = long, y = lat,
color = source)) +
labs(
title= "New York City Pizza Restaurant Locations and Squirrel Sightings",
x = "Longitude",
y = "Latitude"
)

library(tidyverse)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(mapview)
mapview(squirrels_and_pizza, xcol = "long", ycol = "lat", crs = 4269, grid = FALSE, zcol = "source", legend = TRUE)